package com.ketangpai.admin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ketangpai.admin.entity.Course;
import com.ketangpai.admin.entity.UserCourse;
import com.ketangpai.admin.entity.param.CreateCourseParam;
import com.ketangpai.admin.entity.param.JoinCourseParam;
import com.ketangpai.admin.entity.param.UpdateCourseParam;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@Mapper
public interface CourseDao extends BaseMapper<Course> {

    @Select("select *  from course where id=#{courseId}")
    Course getTopCourseById(@RequestBody UserCourse userCourse);

    @Select("select * from course where id=#{courseId}")
    Course selectById(@RequestParam Integer courseId);
    @Select("select *  from course where course_code=#{courseCode}")
    Course getByCourseCode(@RequestBody JoinCourseParam joinCourseParam);
    @Select("select *  from course where course_code=#{courseCode}")
    Course getByCode(@RequestParam String code);

    @Update("UPDATE course SET course_name = #{courseName}, clazz = #{clazz}, course_detail = #{courseDetail}, "
            + "course_location = #{courseLocation}, semester = #{semester}, academic_year = #{academicYear}, "
            + "course_hour = #{courseHour} WHERE id = #{id}")
    Boolean updateCourseById(@RequestBody UpdateCourseParam updateCourseParam);

//    @Insert("INSERT INTO course ")
//    boolean create(@RequestBody Course course);
}
